home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / LITTLE / P3SRC.ZIP / ATARI / OCTREE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-09  |  2.9 KB  |  90 lines

  1. /************************************************************************
  2. *  Oct-tree routine prototypes.  Use by Radiosity calculation routies.
  3. *  Implemented by and (c) 1994 Jim McElhiney, mcelhiney@acm.org or cserve 71201,1326
  4. *  All standard POV distribution rights granted.  All other rights reserved.
  5. *
  6. *************************************************************************/
  7.  
  8. #ifndef OCTREE_H
  9. #define OCTREE_H
  10.  
  11.  
  12.  
  13. /*****************************************************************************
  14. * Global preprocessor defines
  15. ******************************************************************************/
  16.  
  17. #define OT_BIAS 10000000.
  18.  
  19. #define MAX3(a,b,c) ( ((a)>(b)) ? max((a),(c)) : max((b),(c)) )
  20.  
  21.  
  22. /*****************************************************************************
  23. * Global typedefs
  24. ******************************************************************************/
  25.  
  26. typedef struct ot_block_struct OT_BLOCK;
  27. typedef struct ot_id_struct OT_ID;
  28. typedef struct ot_node_struct OT_NODE;
  29.  
  30. /* Each node in the oct-tree has a (possibly null) linked list of these
  31.    data blocks off it.  */
  32. struct ot_block_struct
  33. {
  34.   OT_BLOCK *next;
  35.   VECTOR Point, S_Normal;
  36.   float  drdx, dgdx, dbdx,  drdy, dgdy, dbdy,  drdz, dgdz, dbdz;
  37.   RGB    Illuminance;
  38.   float  Harmonic_Mean_Distance, Nearest_Distance;
  39.   VECTOR To_Nearest_Surface;
  40.   short  Bounce_Depth;
  41. };
  42.  
  43. /* This is the information necessary to name an oct-tree node. */
  44. struct ot_id_struct
  45. {
  46.   long x, y, z;
  47.   long Size;
  48. };
  49.  
  50. /* These are the structures that make up the oct-tree itself, known as nodes */
  51. struct ot_node_struct
  52. {
  53.   OT_ID    Id;
  54.   OT_BLOCK *Values;
  55.   OT_NODE  *Kids[8];
  56. };
  57.  
  58.  
  59. /*****************************************************************************
  60. * Global variables
  61. ******************************************************************************/
  62.  
  63.  
  64.  
  65. /*****************************************************************************
  66. * Global functions
  67. ******************************************************************************/
  68.  
  69. void ot_ins PARAMS((OT_NODE **root, OT_BLOCK *new_block, OT_ID *new_id));
  70. void ot_list_insert PARAMS((OT_BLOCK **list_ptr, OT_BLOCK *item));
  71. void ot_newroot PARAMS((OT_NODE **root_ptr));
  72. long ot_dist_traverse PARAMS((OT_NODE *subtree, VECTOR point, int bounce_depth,  \
  73.                long (*func)(OT_BLOCK *block, void *handle1), void *handle2));
  74. long ot_point_in_node PARAMS((VECTOR point, OT_ID *node));
  75. void ot_index_sphere PARAMS((VECTOR point, DBL radius, OT_ID *id));
  76. void ot_index_box PARAMS((VECTOR min_point, VECTOR max_point, OT_ID *id));
  77. void ot_parent PARAMS((OT_ID *dad, OT_ID *kid));
  78. long ot_save_tree PARAMS((OT_NODE *rootptr, FILE *fd));
  79. long ot_write_block PARAMS((OT_BLOCK *bl, void * handle));
  80. long ot_free_tree PARAMS((OT_NODE **ppRoot));
  81. long ot_read_file PARAMS((FILE * fd));
  82.  
  83.  
  84. /* a trunc function which always returns the floor integer */
  85. long Trunc PARAMS((DBL value));
  86.  
  87.  
  88.  
  89. #endif
  90.